package liveData.migration.toPhoenix.util;

import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: LiveDataMigrationToPhoenix
 * @description:
 * @author: sunteng
 * @create: 2020-04-28 15:57
 **/
@Slf4j
public class ParseHelper {

    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public Long parseVarchar(String time) {

        if (StringUtils.isEmpty(time)) {
            return null;
        }
        try {
            Date dateTime = simpleDateFormat.parse(time);
            return Long.valueOf(dateTime.getTime());
        } catch (Exception e) {
            log.error("##error is [{}] ", e.getMessage());
        }

        return null;
    }
}
